{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  肖丽雯\n",
    "+ 学号  0164513"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "非贫困户不需要扶贫\n",
      "\n",
      "贫困户\n",
      "义务教育保障需要扶贫\n",
      "住房安全需要扶贫\n",
      "饮水安全需要扶贫\n",
      "肉蛋奶豆需要扶贫\n",
      "扶贫失败\n",
      "\n",
      "贫困户\n",
      "义务教育保障需要扶贫\n",
      "住房安全需要扶贫\n",
      "饮水安全需要扶贫\n",
      "肉蛋奶豆需要扶贫\n",
      "扶贫成功\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class pingkunhu(object):\n",
    "    def __init__(self,year,structure,level,times):\n",
    "        self.education = year\n",
    "        self.house = structure\n",
    "        self.water = level\n",
    "        self.food = times\n",
    "    \n",
    "    def panduan(self):\n",
    "        s=0\n",
    "        if self.education < 9 :\n",
    "            s += 1\n",
    "        else :\n",
    "            s += 0 \n",
    "        if self.house == \"不稳定\":\n",
    "            s += 1\n",
    "        else :\n",
    "            s += 0\n",
    "        if self.water<3:\n",
    "            s += 0\n",
    "        else :\n",
    "            s += 1\n",
    "        if self.food >= 2:\n",
    "            s += 0\n",
    "        else :\n",
    "            s += 1\n",
    "        if s > 2:\n",
    "            print(\"贫困户\")\n",
    "            if self.education<9:\n",
    "                print(\"义务教育保障需要扶贫\")\n",
    "            if self.house == \"不稳定\":\n",
    "                print(\"住房安全需要扶贫\")\n",
    "            if self.water>2:\n",
    "                print(\"饮水安全需要扶贫\")\n",
    "            if self.food <2:\n",
    "                print(\"肉蛋奶豆需要扶贫\")\n",
    "        else:\n",
    "             print(\"非贫困户不需要扶贫\\n\")\n",
    "    \n",
    "    def fupin(self,year,structure,level,times):\n",
    "        self.education = year\n",
    "        self.house = structure\n",
    "        self.water = level\n",
    "        self.food = times\n",
    "        s=0\n",
    "        if self.education < 9 :\n",
    "            s += 1\n",
    "        else :\n",
    "            s += 0 \n",
    "        if self.house == \"不稳定\":\n",
    "            s += 1\n",
    "        else :\n",
    "            s += 0\n",
    "        if self.water<3:\n",
    "            s += 0\n",
    "        else :\n",
    "            s += 1\n",
    "        if self.food >= 2:\n",
    "            s += 0\n",
    "        else :\n",
    "            s += 1\n",
    "        if s < 3:\n",
    "            print(\"扶贫成功\\n\")\n",
    "        else:\n",
    "            print(\"扶贫失败\\n\")\n",
    "            \n",
    "moujia = pingkunhu(5,\"稳定\",3,3)\n",
    "moujia.panduan()\n",
    "\n",
    "moujia = pingkunhu(5,\"不稳定\",3,1)\n",
    "moujia.panduan()\n",
    "moujia.fupin(7,\"不稳定\",3,2)\n",
    "\n",
    "moujia = pingkunhu(5,\"不稳定\",3,1)\n",
    "moujia.panduan()\n",
    "moujia.fupin(10,\"稳定\",3,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "萌萌的分数为100睡眠时间为5\n",
      "BIM可能偏大\n",
      "\n",
      "Lily的分数为90睡眠时间为7\n",
      "体重正常\n",
      "\n",
      "卡西的分数为90睡眠时间为6\n",
      "BIM可能偏大\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class Student(object):\n",
    " \n",
    "  def __init__(self,name,score,sleep):\n",
    "    self.name = name\n",
    "    self.score = score\n",
    "    self.sleep = sleep\n",
    "    \n",
    "  def get_grade(self):\n",
    "    if self.score > 90 and self.sleep < 6:\n",
    "        self.panduan='BIM可能偏大\\n' \n",
    "    else:\n",
    "        self.panduan= '体重正常\\n'\n",
    "    print(self.panduan)\n",
    "    \n",
    "  def get_grade_change(self,c1,c2):\n",
    "    if self.score > c1 and self.sleep < c2:\n",
    "        self.panduan='BIM可能偏大\\n' \n",
    "    else:\n",
    "        self.panduan= '体重正常\\n'\n",
    "    print(self.panduan)\n",
    "\n",
    "mouren= Student (\"萌萌\",100,5.4)\n",
    "print(\"%s的\"%mouren.name+\"分数为%d\"%mouren.score+\"睡眠时间为%d\"%mouren.sleep)\n",
    "mouren.get_grade()\n",
    "\n",
    "mouren=Student(\"Lily\",90,7)\n",
    "print(\"%s的\"%mouren.name+\"分数为%d\"%mouren.score+\"睡眠时间为%d\"%mouren.sleep)\n",
    "mouren.get_grade_change(85,7)\n",
    "\n",
    "mouren=Student(\"卡西\",90,6)\n",
    "print(\"%s的\"%mouren.name+\"分数为%d\"%mouren.score+\"睡眠时间为%d\"%mouren.sleep)\n",
    "mouren.get_grade_change(85,7)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sam体重正常\n",
      "KateBIM可能偏大\n",
      "Marry趋于正常\n"
     ]
    }
   ],
   "source": [
    "class member(Student):\n",
    "    \n",
    "    def __init__(self,name,score,sleep,running):\n",
    "        super().__init__(name,score,sleep)\n",
    "        self.running=running\n",
    "\n",
    "    def yuce(self,c1,c2):\n",
    "        if  self.score <= c1 or self.sleep >= c2:\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        elif self.score > c1 and self.sleep < c2 and self.running>30:\n",
    "            print(\"%s趋于正常\"%self.name)\n",
    "        else:\n",
    "            print(\"%sBIM可能偏大\"%self.name)\n",
    "    \n",
    "ta=member(\"Sam\",100,7,30)\n",
    "ta.yuce(90,6)\n",
    "\n",
    "ta=member(\"Kate\",100,5,30)\n",
    "ta.yuce(90,6)\n",
    "\n",
    "ta=member(\"Marry\",100,5,40)\n",
    "ta.yuce(90,6)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
